﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace xiaolanshu
{
    public partial class 底妆评价 : Form
    {
        public 底妆评价()
        {
            InitializeComponent();
        }

        

        private void uiButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
         private void 底妆评价_Load(object sender, EventArgs e)
                {
                    SqlConnection conn = SQLTools.conn;
                    string sql = "select 名称 from 底妆";
                    SqlCommand cmd = new SqlCommand(sql, conn);
            if (cmd.Connection.State == ConnectionState.Open)
            {
                cmd.Connection.Close();
            }
            conn.Open();
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        comboBox1.Items.Add(rd[0].ToString());
                    }
                    rd.Close();
                    conn.Close();
                }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection conn = SQLTools.conn;
            string sql = @"select AVG(整体评价) AS zt,AVG(服帖度) AS ftd,AVG(持妆度) AS czd,AVG(遮瑕力) AS zxl from 底妆反馈 where 产品='"+comboBox1.Text+"'";
            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            if (rd.Read())
            {
                textBox1.Text = rd["zt"].ToString();
                textBox2.Text = rd["ftd"].ToString();
                textBox3.Text = rd["czd"].ToString();
                textBox4.Text = rd["zxl"].ToString();
            }
            rd.Close();
            conn.Close();
            string sql1 = @"select 产品,整体评价,服帖度,持妆度,遮瑕力 from 底妆反馈 where 产品='" + comboBox1.Text + "'";
            SqlDataAdapter ad = new SqlDataAdapter(sql1,conn);
            DataSet ds = new DataSet();
            ad.Fill(ds, "t");
            dataGridView1.DataSource = ds.Tables["t"];

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            if (int.Parse(textBox2.Text) < 90)
            {
                label7.Text = "此项评分过低！";
            }
            else 
            {
                label7.Text = "";
            }
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            if (int.Parse(textBox3.Text) < 90)
            {
                label8.Text = "此项评分过低！";
            }
            else
            {
                label8.Text = "";
            }
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {
            if (int.Parse(textBox4.Text) < 90)
            {
                label9.Text = "此项评分过低！";
            }
            else
            {
                label9.Text = "";
            }
        }
    }
}
